package top.chj.day17.exam.test2;

/**
 * @Auther:小陈的Java
 */
//实现Runnable接口创建多线程
public class Demo2 {
    public static void main(String[] args) {
        Thread thread1 = new Thread(new Runnable1(),"线程1");
        Thread thread2 = new Thread(new Runnable2(),"线程2");
        thread1.start();
        thread2.start();
    }
}
class Runnable1 implements Runnable{
    @Override
    public void run() {
        for (int i = 0;i<100;i++){
            try {
                Thread.sleep(10);
                System.out.println(i);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
class Runnable2 implements Runnable{
    @Override
    public void run() {
        for (int i = 0;i<100;i++){
            try {
                Thread.sleep(10);
                System.out.println(i);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}